//
//  HamatonDiagnoseViewController.swift
//  hamaton-app
//
//  Created by intyt on 2024/4/8.
// 诊断页面

import UIKit
import SnapKit

class HamatonDiagnoseViewController: HamatonBaseViewController {
    let deviceData = DeviceData()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .clear
        navigationItem.title = "设备诊断"
        tableView.snp.makeConstraints { (make) in
            make.top.left.right.bottom.equalToSuperview()
        }        // Do any additional setup after loading the view.
    }
    

    lazy var tableView: UITableView = {
        let tv = UITableView.init(frame: CGRect.zero, style: .grouped)
        tv.backgroundColor = UIColor.white
        tv.separatorStyle = .none
        //tv.delegate = self
        tv.dataSource = self
      //  tv.tableHeaderView = headerView
        tv.register(HamatonDiagnoseTableViewCell.self, forCellReuseIdentifier: "HamatonDiagnoseTableViewCell")
        view.addSubview(tv)
        return tv
    }()

}

extension HamatonDiagnoseViewController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 6
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//        if indexPath.row >= 0 && indexPath.row < 7{
            let cell = tableView.dequeueReusableCell(withIdentifier: "HamatonDiagnoseTableViewCell", for: indexPath) as! HamatonDiagnoseTableViewCell
            if (indexPath.row == 0) {
                cell.titleLabel.text = "常规诊断：" + deviceData.changgui!
                cell.numLabel.text = "计数：" + deviceData.changguiNum!
            } else if (indexPath.row == 1) {
                cell.titleLabel.text = "CAN诊断：" + deviceData.CAN!
                cell.numLabel.text = "计数：" + deviceData.CANNum!
            } else if (indexPath.row == 2) {
                cell.titleLabel.text = "RF芯片诊断：" + deviceData.RFXinpian!
                cell.numLabel.text = "计数：" + deviceData.RFXinpianNum!
            }  else if (indexPath.row == 3) {
                cell.titleLabel.text = "UART诊断：" + deviceData.UART!
                cell.numLabel.text = "计数：" + deviceData.UARTNum!
            } else if (indexPath.row == 4) {
                cell.titleLabel.text = "CAN芯片诊断：" + deviceData.CANXinpian!
                cell.numLabel.text = "计数：" + deviceData.CANXinpianNum!
            } else if (indexPath.row == 5) {
                cell.titleLabel.text = "LPW诊断：" + deviceData.LPW!
                cell.numLabel.text = "计数：" + deviceData.LPWNum!
            }
            return cell
 //       }
//        let cell = tableView.dequeueReusableCell(withIdentifier: "HamatonDiagnoseTableViewCell", for: indexPath) as! HamatonDiagnoseTableViewCell
//        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 200
    }
    
}



